package controller

import (
	"gin/response"
	"gin/service"
	"gin/types"
	"github.com/gin-gonic/gin"
)

var (
	departmentService = service.Department{}
)

type Department struct {
}

// DeleteCheck 部门删除检查
func (d *Department) DeleteCheck(ctx *gin.Context) {
	var req types.DepartmentDeleteCheckReq
	err := ctx.ShouldBindJSON(&req)

	if err != nil {
		response.Fail(ctx, nil, err.Error())
		return
	}

	resData, queryErr := departmentService.DeleteCheck(req.DepartmentIdList)
	if queryErr != nil {
		// 查询失败
		response.Fail(ctx, nil, queryErr.Error())
	} else {
		// 查询成功
		response.Success(ctx, gin.H{"data": resData}, "success")
	}
}
